home *** CD-ROM | disk | FTP | other *** search
- /*==================================================================
- File: ZStringData.h
-
- Contains: Data backing object for ZStrings.
-
- Written by: Eric Traut
-
- Copyright: 2000-2001 Connectix Corporation
-
- This source has been placed into the public domain by
- Connectix Corporation. You have the right to modify,
- distribute or use this code without any legal limitations
- or finanicial/licensing requirements. Connectix is not
- liable for any problems that result from the use of this
- code.
-
- If you have comments, feedback, questions, or would like
- to submit bug fixes or updates to this code, please email
- opensource@connectix.com.
- ==================================================================*/
-
- #ifndef __ZSTRINGDATA__
- #define __ZSTRINGDATA__
-
-
- #include "ZStringTypes.h"
-
-
- /*==================================================================
- ZStringData
- ==================================================================*/
-
- class ZStringData
- {
- friend class ZString;
- friend class ZStringParser;
-
- public:
- static ZStringData *
- Allocate(
- Z_UInt32 inStringLength);
-
- void
- Deallocate();
-
- inline Z_UInt32
- GetLength()
- {
- return mStringLength;
- }
-
- const char *
- GetStringData()
- {
- return mStringData;
- }
-
- void
- IncrementRefCount()
- {
- mRefCount++;
- }
-
- void
- DecrementRefCount()
- {
- check(mRefCount > 0);
- mRefCount--;
-
- if (mRefCount == 0)
- Deallocate();
- }
-
- private:
- void
- FillInString(
- const char * inString,
- Z_UInt16 inOffset,
- Z_UInt16 inLength);
-
- char *
- GetDataArray()
- {
- return mStringData;
- }
-
- ZStringData()
- {
- // The normal constructor is unreachable.
- }
-
- Z_UInt16 mRefCount;
- Z_UInt16 mStringLength;
-
- // Data follows here in a variable-sized array.
- char mStringData[1];
- };
-
-
- #endif // __ZSTRINGDATA__
-
-
-